<template>
	<div style="position: relative;height: 100%;">
		<div v-if="teacherSettingHidden || teacherAccountShow" style="width: 100%;height: 100%;background-color: rgba(247,247,247,0.8);position: absolute;top: 20px;z-index: 999;"></div>
		<div style="width: 100%;height: 20px;background-color: #ebedf0;"></div>
		<!--教师任课-->
		<div style="padding: 20px;">
			<Row >
		        <Col span="24" style="text-align: left;margin-top:15px;">
		        	<span>年级：</span>
		        	<RadioGroup  v-model="gradeSelect" type="button" @on-change="gradeChange">
		        		<Radio v-for="item in gradeList" :key="item.value" :label="item.value">{{item.label}}</Radio>
				    </RadioGroup>
		        </Col>
		    </Row>
		    <Row >
		        <Col span="24" style="text-align: left;margin-top:15px;">
		        	<span>班级：</span>
		        	<RadioGroup  v-model="classesSelect" type="button" @on-change="classesChange">
		        		<Radio v-for="item in classesList" :key="item.value" :label="item.value">{{item.label}}</Radio>
				    </RadioGroup>
		        </Col>
		    </Row>
		</div>
		<Row style="text-align: left;margin-top: 20px;">
			<Col span="12" style="text-align: left;">
    			<span style="border-left: 5px solid #517EDB;font-size: 16px;"></span>
    			<span style="font-size: 16px;font-weight: 800;margin-left: 41px;">教师任课列表</span>
    			<!--<span style="font-size: 12px;margin-left: 12px;color: rgba(102, 102, 102, 0.61);">均差=教师评价值  - 平均评价值</span>-->
    		</Col>
			<Col span="11" style="text-align: right;">
				<Tooltip content="导出账号信息" theme="light" placement="top">
		        	<Button style="background-color: #4496fc;" size="small" :loading="loading" @click="exportexl">
		        		<span v-if="!loading"><img style="width: 20px;margin-top: 2px;" src="../../../../static/img/export.png" alt="" /></span>
				        <span v-else>加载中</span>
		        	</Button>
	        	</Tooltip>
	        	<Tooltip content="查看账号信息" theme="light" placement="top">
					<Button @click="getteacherAccount"  type="success" size="small"><i class="iconfont alicon-mingxi3"></i></Button>
				</Tooltip>
				<Tooltip content="添加任课关系" theme="light" placement="top">
	        		<Button @click="addTeacherAndCancel"  type="success" size="small"><i class="iconfont alicon-add1"></i></Button>
	        	</Tooltip>
	        	<Tooltip content="编辑教师" theme="light" placement="top">
	        		<Button @click="editTeacher" type="warning" size="small"><i class="iconfont alicon-write"></i></Button>
	        	</Tooltip>
	        	<Tooltip content="删除任课关系" theme="light" placement="top">
	        		<Button @click="delteacher" type="error" size="small"><i class="iconfont alicon-delete"></i></Button>
	        	</Tooltip>
	       </Col>
		</Row >
		<div style="padding: 10px 20px 20px 20px;">
	    	<div style="position: relative;">
			    <Table  border ref="selection" :columns="columns4" :data="data1" @on-selection-change="tableteacherselect"></Table>
		        <!--<Spin size="large" fix v-if="tableshow"></Spin>-->
	        </div>
	        <Page style="text-align: center;margin-top:15px;" :current="current" :total="recordCount" @on-change="pageChange"/>
	    </div>
	    
	    
	    
	    <div v-if="teacherSettingHidden" style="z-index: 1000;float: left;width: 850px;height: 500px;background-color: white;border-radius: 15px;margin: auto;position: absolute;top: 200px;left: 0;right: 0;">
			<Row >
				<Col span="10" style="text-align: left;height:500px;border: 1px solid #e9eaec;padding: 10px;border-top-left-radius: 15px;border-bottom-left-radius: 15px;">
	    			<Row style="margin-bottom:15px;margin-top: 5px;line-height: 32px;">
	    				<Col span="4" style="text-align: center;">
							年级:
					    </Col>
			        	<Col span="20" style="text-align: center;">
				            <Select placeholder="请选择年级" v-model="settingGradeSelect" style="width:95%" @on-change="settingGradeSelectChange">
						        <Option v-for="item in settingGradeList" :value="item.value" :key="item.value">{{ item.label }}</Option>
						    </Select>
					    </Col>
					</Row>
					<!--<div style="width:100%;height:1px;border-bottom: 1px solid #e9eaec;margin:10px 0px;"></div>-->
					<Row  style="margin-bottom:10px;line-height: 32px;">
	    				<Col span="4" style="text-align: center;">
							班级:
					    </Col>
			        	<Col span="20" style="text-align: center;">
				            <Select placeholder="请选择班级" v-model="settingClassesSelect" style="width:95%" @on-change="settingClassesSelectChange">
						        <Option v-for="item in settingClassesList" :value="item.value" :key="item.value">{{ item.label }}</Option>
						    </Select>
					    </Col>
					</Row>
					<Row  style="margin-bottom:10px;line-height: 32px;">
	    				<Col span="4" style="text-align: center;">
							任课:
					    </Col>
			        	<Col span="20" style="text-align: center;">
				            <Select placeholder="请选择任课" v-model="settingTeachSelect" style="width:95%" @on-change="settingTeachSelectChange">
						        <Option v-for="item in settingTeachList" :value="item.value" :key="item.value">{{ item.label }}</Option>
						    </Select>
					    </Col>
					</Row>
					
					<Row  style="line-height: 38px;">
	    				<Col span="6" style="text-align: center;font-weight: bold;font-size: 15px;">
							所选教师:
					    </Col>
					</Row>
					<Row  style="margin-bottom:10px;line-height: 38px;">
			        	<Col span="24" style="text-align: center;">
			        		<Row  >
					            <div v-for="item in teacherselect">
			        				<Col span="8"  style="text-align: center;margin-bottom:10px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 100px;height: 38px;line-height: 38px;border-radius: 5px;border: 1px solid #dddee1;background-color: #f7f7f7;">
					        				{{item.label}}
					        				<i style="font-size: 15px;" @click="choose" :label="item.label" :value="item.value" class="iconfont alicon-close_light"></i>
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					</Row>
					<Row  style="line-height: 38px;">
	    				<Col span="6" style="text-align: center;font-weight: bold;font-size: 15px;">
							全部教师:
					    </Col>
					</Row>
					<Row  style="margin-bottom:10px;line-height: 20px;border: 1px solid #e9eaec;">
			        	<Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			班主任：
				        		</Col>
					            <div v-for="item in classMasterList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					    <Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			语文：
				        		</Col>
					            <div v-for="item in chiTeacherList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					    <Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			数学：
				        		</Col>
					            <div v-for="item in mathTeacherList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					    <Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			英语：
				        		</Col>
					            <div v-for="item in engTeacherList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					    <Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			物理：
				        		</Col>
					            <div v-for="item in phyTeacherList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					    <Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			化学：
				        		</Col>
					            <div v-for="item in chemTeacherList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					    <Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			生物：
				        		</Col>
					            <div v-for="item in bioTeacherList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					    <Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			历史：
				        		</Col>
					            <div v-for="item in hisTeacherList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					    <Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			地理：
				        		</Col>
					            <div v-for="item in geoTeacherList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					    <Col span="12" style="text-align: center;">
			        		<Row  >
			        			<Col span="8"  style="text-align: right;margin-bottom:5px;">
				        			政治：
				        		</Col>
					            <div v-for="item in polTeacherList">
			        				<Col span="6"  style="text-align: center;margin-bottom:5px;">
					        			<div style="cursor:pointer;margin: 0 auto;width: 50px;height: 20px;line-height: 20px;">
					        				{{item.label}}
					        			</div>
					        		</Col>
			        			</div>
			        		</Row>
					    </Col>
					</Row>
					
					<Row  style="line-height: 38px;position: absolute;bottom: 10px;width: 100%;margin-left: -10px;">
						<div style="padding: 10px;width: 100%;">
							<!--<div style="width:100%;height:1px;border-bottom: 1px solid #e9eaec;"></div>-->
						</div>
	    				<Col span="12" style="text-align: center;">
							<Button  @click="addTeacherAndCancel"  style="width: 105px;">取消</Button>
					    </Col>
			        	<Col span="12" style="text-align: center;">
				            <Button @click="saveteacher" type="primary" style="width: 105px;">保存当前老师</Button>
					    </Col>
					</Row>
	    		</Col>
				<Col span="14" style="text-align: left;height:500px;border: 1px solid #e9eaec;border-top-right-radius: 15px;border-bottom-right-radius: 15px;">
					<i style="font-size: 15px;position: absolute;cursor: pointer;right: 10px;top: 10px;" @click="addTeacherAndCancel" class="iconfont alicon-close_light"></i>
		        	<Row style="height: 33px;text-align: center;margin-top: 25px;">
		        		<Col span="6" style="text-align: right;line-height: 33px;">
		        			快速搜索：
		        		</Col>
		        		<Col span="18" style="text-align: left;">
		        			<Input v-model="settingSearchInfo" icon="ios-search" @on-click="settingSearchTeacher" @on-enter="settingSearchTeacher" placeholder="首字母/姓名/账号/手机号" style="width: 90%;cursor: pointer;"></Input>
		        		</Col>
	        		</Row >
	        		
	        		<Row style="height: 400px;overflow-y: scroll;padding: 10px;border: 1px solid #e9eaec;margin: 20px;">
	        			<div v-for="(item,key) in teacherList">
			        		<Row >
			        			<Col v-show="teacherList[key].length>0? true:false" span="4"  style="text-align: center;margin-bottom:10px;font-size: 16px;">
			        				{{key}}
			        			</Col>
			        		</Row >
			        		<Row >
			        			<div @click="choose" v-for="items in item">
			        				<Col span="6"  style="text-align: center;margin-bottom:10px;">
					        			<div tag="button" v-bind:class="[teacherselectshow.indexOf(items.value)>-1?activeclass:'']" :label="items.label" :value="items.value" style="cursor:pointer;margin: 0 auto;width: 80px;height: 38px;border:1px solid #e9eaec;line-height: 38px;border-radius: 5px;">
					        				{{items.label}}
					        			</div>
					        		</Col>
			        			</div>
				        		
			        		</Row >
			        	</div>
	        		</Row >
		       </Col>
			</Row >
		</div>
	    
	    
	    
	    <div v-if="teacherAccountShow" style="z-index: 1000;float: left;border: 1px solid #e9eaec;width: 450px;height: 450px;background-color: white;border-radius: 15px;margin: auto;position: absolute;top: 200px;left: 0;right: 0;">
			<Row style="padding:15px 10px 0px 10px;">
				<i style="font-size: 15px;cursor: pointer;text-align: right;position: absolute;top: 10px;right: 10px;" @click="closeTeacherAccountShow"  class="iconfont alicon-close_light"></i>
				<!--<Table  border ref="selection1" :row-height="10"  :column-cell-class-name="columnCellClass" :columns="columns5" :data="data2" ></Table>-->
				<div style="min-height: 300px;">
					<Row style="margin:0 auto;margin-left:20px;margin-right:20px;margin-top:0px;margin-bottom:5px;color: #666666;border-radius: 12px;background-color: #f0f8ff;">
				        <Col span="8" style="text-align: center;">
							<span style="font-size: 16px;">任课</span>
						</Col>
						<Col span="8" style="text-align: center;">
							<span style="font-size: 16px;">姓名</span>
						</Col>
						<Col span="8" style="text-align: center;">
							<span style="font-size: 16px;">账号</span>
						</Col>
					</Row>
					<Row  v-for="item in data2" :key="item.account" style="margin:0 auto;color: #666666;margin: 5px 20px 5px 20px;padding:5px 0px 5px 0px;border-bottom: 1px solid rgb(240, 248, 255);">
				       
					        <Col span="8" style="text-align: center;">
								<span style="font-size: 16px;">{{item.teachSelectName}}&nbsp;</span>
							</Col>
							<Col span="8" style="text-align: center;">
								<span style="font-size: 16px;">{{item.teacherName}}&nbsp;</span>
							</Col>
							<Col span="8" style="text-align: center;">
								<span style="font-size: 16px;">{{item.account}}&nbsp;</span>
							</Col>
					</Row>
			    </div>
			</Row >
		</div>
	    
	    
	</div>
</template>

<script>
	import api from "@/components/js/Apidomain.js"
	export default{
		data(){
			return{
				gradeSelect:"",							//年级
				classesSelect:"",						//班级
				
				gradeList: [ ], 				//年级选择列表
				classesList:[ ],				//班级选择列表
				
				searchInfo:"",				//搜索的关键字
		        selections:"",				//表格的选择合集
		        //分页
		        recordCount:0,				//总条数
				current:1,					//页码
				
				columns4: [
                    {type: 'selection',width: 60,align: 'center'},
                    {title: '年级',key: 'gradeName',align: 'center',},
                    {title: '班级',key: 'classesNo',align: 'center',},
                    {title: '班主任',key: 'master',align: 'center',},
                    {title: '语文',key: 'chi',align: 'center',},
                    {title: '数学',key: 'math',align: 'center',},
                    {title: '英语',key: 'eng',align: 'center',},
                    {title: '物理',key: 'phy',align: 'center',},
                    {title: '化学',key: 'chem',align: 'center',},
                    {title: '生物',key: 'bio',align: 'center',},
                    {title: '历史',key: 'his',align: 'center',},
                    {title: '地理',key: 'geo',align: 'center',},
                    {title: '政治',key: 'pol',align: 'center',},
                    
                    
                ],
                data1: [
//                  {id:"4444",teacherNo:"122672013040",teacherName: '张三',subject: '语文',jobTitle: '初一'},
                ],
                
                //------------教师设置框里面
		        teacherSettingHidden:false,				//控制设置教师框的显示隐藏
		        teacherList:{
//		        	A:[{value: "7ef7a98fac4c48cd9795d031aaba8892", label: "安华"},{value: "7efdv98fac4c48cd9795d031aaba8892", label: "安华2"}],
//		        	B:[{value: "5658b629a1ae40fb98900909641b8842", label: "方艳斌"}]
		        },
		        teacherselect:[],							//根据条件请求服务器返回的老师数据
		        teacherselectshow:[],			//面板中的选中的颜色不一样的数据 "fe3e3cb22fa24852981f0dd1cacf0a54","df7cecdfae844a80ac8d94b11e246400"存这样的
		        settingSearchInfo:"",
		        settingGradeSelect:"",
		        settingClassesSelect:"",
		        settingTeachSelect:"",
		        
		        settingGradeList:[],
		        settingClassesList:[],
		        settingTeachList:[],
		        
		        
		        classMasterList: [], //班主任
		        chiTeacherList: [], //语文老师
		        mathTeacherList: [], //数学老师
		        engTeacherList: [],//英语老师
		        phyTeacherList: [],//物理老师
		        chemTeacherList: [],//化学老师
		        bioTeacherList: [],//生物老师
		        hisTeacherList: [],//历史老师
		        polTeacherList: [],//政治老师
		        geoTeacherList: [],//地理老师  
		        
		        loading: false,				//下载模板按钮上的加载中显示隐藏
		        
		        //教师账号
		        teacherAccountShow:false,
                data2: [
//                  {id:"4444",teacherNo:"122672013040",teacherName: '张三',subject: '语文',jobTitle: '初一'},
                ],
			}
		},
		created(){
			this.getTchGradeSelect()
		},
		computed:{
			activeclass: function() {
				return 'active'
			},
		},
		methods:{
			//获取年级选择列表
			getTchGradeSelect:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getTchGradeSelect';
            	this.$http.post(url).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.gradeList = response.data.data
						if(self.gradeList.length != 0){
							self.gradeSelect = self.gradeList[0].value;
							self.getTchClassesSelect();
						}
	            }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00060',
							duration: 10,
							closable: true
						});
				});
			},
			//年级改变触发函数
			gradeChange:function(){
				this.getTchClassesSelect()
			},
			//获取班级选择列表
			getTchClassesSelect:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getTchClassesSelect';
            	this.$http.post(url,{"gradeId":this.gradeSelect}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.classesList = response.data.data
						if(self.classesList.length != 0){
							self.classesSelect = self.classesList[0].value;
							self.current = 1;
							self.getClassesTeacherInfo()
						}
	            }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00061',
							duration: 10,
							closable: true
						});
				});
			},
			//班级改变触发函数
			classesChange:function(){
				this.current = 1;
				this.getClassesTeacherInfo()
			},
			tableteacherselect:function(selection){
           		this.selections = selection
           	},
			//获取教师任职列表
           	getClassesTeacherInfo:function(){
//         		this.tableshow = true;
//				let sessionroleid = getsessionstorage('roleid');
           		var senddata = { 
           			"current":this.current,
					"pageSize":"10",
           			"gradeId":this.gradeSelect,
					"classesId":this.classesSelect
				}
           		var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getClassesTeacherInfo';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
						
//						console.log(response.data.data)
						self.data1 = response.data.data.items
						self.recordCount = response.data.data.recordCount
//						self.tableshow = false;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
//		            		self.tableshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00062',
							duration: 10,
							closable: true
						});
//						self.tableshow = false;
					});
           	},
           	pageChange:function(value){
        		this.current = value;
        		this.getClassesTeacherInfo()
        	},
        	
        	
        	
        	//勾选教师编辑部分
			editTeacher:function(){
				if(this.selections.length != 1){
					this.$Message.error({
								content: '请选择单条数据',
								duration: 10,
								closable: true
							});	
					return;
				}
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getEditInitAllSelectFromTeacherInClass';
            	this.$http.post(url, {"gradeId": this.selections[0].gradeId,"classesId":this.selections[0].classesId }).then(function(response) {
					if(response.data.success == true){
						console.log(response.data.data)
						
						self.settingGradeList = response.data.data.gradeSelectList
						self.settingClassesList = response.data.data.classesSelectList
						self.settingTeachList = response.data.data.teachSelectList
						
						self.settingGradeSelect = response.data.data.gradeSelectListValue
				        self.settingClassesSelect = response.data.data.classesSelectListValue
				        self.settingTeachSelect = response.data.data.teachSelectListValue
				        
				        self.classMasterList = response.data.data.classMasterList //班主任
				        self.chiTeacherList = response.data.data.chiTeacherList 					//语文老师
				        self.mathTeacherList = response.data.data.mathTeacherList 					//数学老师
				        self.engTeacherList = response.data.data.engTeacherList					//英语老师
				        self.phyTeacherList = response.data.data.phyTeacherList					//物理老师
				        self.chemTeacherList = response.data.data.chemTeacherList					//化学老师
				        self.bioTeacherList = response.data.data.bioTeacherList					//生物老师
				        self.hisTeacherList = response.data.data.hisTeacherList					//历史老师
				       	self.polTeacherList = response.data.data.polTeacherList					//政治老师
				        self.geoTeacherList = response.data.data.geoTeacherList						//地理老师  
						
						self.teacherselect = response.data.data.curTeacherList
						self.teacherselectshow = [];
           				var showdata = response.data.data.curTeacherList;
           				for(let i = 0;i<showdata.length;i++){
           					self.teacherselectshow.push(showdata[i].value)
           				}
//						
						self.teacherList = response.data.data.pinyinResults
						self.teacherSettingHidden = true;
	           	}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00062',
							duration: 10,
							closable: true
						});
				});
			},
        	delteacher:function(){
           		let delallid = [];
           		for(let key in this.selections){
           			delallid.push(this.selections[key].classesId)
           		}
           		if(delallid.length == 0){
           			this.$Message.error({
								content: '请勾选再删除',
								duration: 10,
								closable: true
							});	
           			return;
           		}
           		this.$Modal.confirm({
                    title: '确定删除',
                    content: '<p>确定删除这些老师信息和年级班级信息吗</p>',
                    onOk: () => {
//		               this.tableshow = true;
		           		var self = this;
		            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/batchDeleteCleanUpTeacherFromInTeach';
		            	this.$http.post(url, {'classesIds':delallid}).then(function(response) {
							if(response.data.success == true){
								self.$Message.success({
				                    content: '删除成功',
				                    duration: 10,
				                    closable: true
		               			})
		//						////console.log(response.data.data)
//								self.tableshow = false;
								self.getClassesTeacherInfo();
				            }else if(response.data.success == false){
				            		self.$Message.error({
										content: response.data.msg,
										duration: 10,
										closable: true
									});	
//				            		self.tableshow = false;
				            	}
							})
							.catch(function(error) {
								self.$Message.error({
									content: '系统发生错误：错误码00063',
									duration: 10,
									closable: true
								});
//								self.tableshow = false;
							}); 
		                
                    },
                    onCancel: () => {
//                      this.$Message.info('Clicked cancel');
                    }
                });	
           	},
        	
        	
        	
        	
        	
        	//································以下为老师设置框
			addTeacherAndCancel:function(){
				if(this.teacherSettingHidden == false){
					this.getAddInitAllSelectFromTeacherInClass();
					this.teacherSettingHidden = true;
				}else{
					this.getClassesTeacherInfo();
					this.teacherSettingHidden = false;
					
					this.teacherselect = []							//根据条件请求服务器返回的老师数据
		        	this.teacherselectshow = []
					
					this.settingGradeSelect = ""
			        this.settingClassesSelect = ""
			        this.settingTeachSelect = ""
			        this.classMasterList = [] //班主任
			        this.chiTeacherList = [] //语文老师
			        this.mathTeacherList = [] //数学老师
			        this.engTeacherList = []//英语老师
			        this.phyTeacherList = []//物理老师
			        this.chemTeacherList = []//化学老师
			        this.bioTeacherList = []//生物老师
			        this.hisTeacherList = []//历史老师
			        this.polTeacherList = []//政治老师
			        this.geoTeacherList = []//地理老师  
			        
				}
			},
			//初始所需年级班级和拼音排序列表
			getAddInitAllSelectFromTeacherInClass:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getAddInitAllSelectFromTeacherInClass';
            	this.$http.post(url, {}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.teacherList = response.data.data.pinyinResults
						self.settingGradeList = response.data.data.gradeSelectList
						self.settingClassesList = response.data.data.classesSelectList
						self.settingTeachList = response.data.data.teachSelectList
	           	}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00064',
							duration: 10,
							closable: true
						});
				});
			},
			settingGradeSelectChange:function(){
				this.getTchClassesNoContainAllSelect()
			},
			settingClassesSelectChange:function(){
				this.getCurTeacherInTeach()
			},
			settingTeachSelectChange:function(){
				this.getCurTeacherInTeach()
				this.settingSearchTeacher()
			},
			choose:function(e){
				let dom = e.target;
				var domlabel = dom.getAttribute("label");
				var domvalue = dom.getAttribute("value");
//				console.log(dom.getAttribute("class"))
//				console.log(domvalue)
				//如果点到空白地方
				if(dom.getAttribute("label") == null){
					return;
				}
				if(dom.getAttribute("class") == "active" || dom.getAttribute("class") == "iconfont alicon-close_light"){
					for(let i = 0;i<this.teacherselect.length;i++){
						if(this.teacherselect[i].value == domvalue){
							this.teacherselect.splice(i,1)
//								//console.log(i)
						}
					}
					for(let i = 0;i<this.teacherselectshow.length;i++){
						if(this.teacherselectshow[i] == domvalue){
							this.teacherselectshow.splice(i,1)
//								//console.log(i)
						}
					}
				}else{
					this.teacherselect.push({value: domvalue,label: domlabel})
					this.teacherselectshow.push(domvalue)
				}
			},
			//根据年级ID获取班级下拉列表
			getTchClassesNoContainAllSelect:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getTchClassesNoContainAllSelect';
            	this.$http.post(url,{"gradeId":this.settingGradeSelect}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.settingClassesList = response.data.data
						if(self.settingClassesList.length != 0){
							self.settingClassesSelect = self.settingClassesList[0].value;
						}
						self.getCurTeacherInTeach()
//						
	            }else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00065',
							duration: 10,
							closable: true
						});
				});
			},
			//设置老师里面的搜索框
			settingSearchTeacher:function(){
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getFilterTchTeacherFristPinyinList';
            	this.$http.post(url, {"subjectId": this.settingTeachSelect,"nameOrAccount":this.settingSearchInfo}).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.teacherList = response.data.data.pinyinResults
//						self.settingrolelist = response.data.data.roleList
						
	           	}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
	            	
				})
				.catch(function(error) {
					self.$Message.error({
							content: '系统发生错误：错误码00066',
							duration: 10,
							closable: true
						});
				});
			},
			//根据下拉列表获得当前老师
			getCurTeacherInTeach:function(){
				var senddata = {
					"gradeId":this.settingGradeSelect,			//年级Id
					"classesId":this.settingClassesSelect,		//班级Id,
					"teachSelectId":this.settingTeachSelect		//任课类型Id 
				}
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getCurTeacherInTeach';
            	this.$http.post(url, senddata).then(function(response) {
					if(response.data.success == true){
						console.log(response.data.data)
						self.teacherselect = response.data.data.curTeacherList
						self.teacherselectshow = [];
           				var showdata = response.data.data.curTeacherList;
           				for(let i = 0;i<showdata.length;i++){
           					self.teacherselectshow.push(showdata[i].value)
           				}
						
						self.classMasterList = response.data.data.classMasterList //班主任
				        self.chiTeacherList = response.data.data.chiTeacherList 					//语文老师
				        self.mathTeacherList = response.data.data.mathTeacherList 					//数学老师
				        self.engTeacherList = response.data.data.engTeacherList					//英语老师
				        self.phyTeacherList = response.data.data.phyTeacherList					//物理老师
				        self.chemTeacherList = response.data.data.chemTeacherList					//化学老师
				        self.bioTeacherList = response.data.data.bioTeacherList					//生物老师
				        self.hisTeacherList = response.data.data.hisTeacherList					//历史老师
				       	self.polTeacherList = response.data.data.polTeacherList					//政治老师
				        self.geoTeacherList = response.data.data.geoTeacherList						//地理老师  
//						self.teacherselect = response.data.data
//						self.teacherselectshow = [];
//         				var showdata = response.data.data;
//         				for(let i = 0;i<showdata.length;i++){
//         					self.teacherselectshow.push(showdata[i].value)
//         				}
	            }else if(response.data.success == false){
//	            		self.loading = false;
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});
	            	}
	            	
				})
				.catch(function(error) {
//					self.loading = false;
					self.$Message.error({
							content: '系统发生错误：错误码00067',
							duration: 10,
							closable: true
						});
				});
			},
			saveteacher:function(){
				var senddata = {
					"gradeId":this.settingGradeSelect,			//年级Id
					"classesId":this.settingClassesSelect,		//班级Id, 
				  	"teachSelectId":this.settingTeachSelect,		//任课类型Id
					"teacherList":this.teacherselectshow 
					
				}
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/saveTeacherInTeach';
            	this.$http.post(url, senddata).then(function(response) {
					if(response.data.success == true){
//						console.log(response.data.data)
						self.$Message.success({
		                    content: response.data.msg,
		                    duration: 10,
		                    closable: true
               			})
						self.getCurTeacherInTeach()
	           		}else if(response.data.success == false){
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
				})
				.catch(function(error) {
					self.loading = false;
					self.$Message.error({
							content: '系统发生错误：错误码00068',
							duration: 10,
							closable: true
						});
				});
			},
			
			
			
			
			//关闭查看教师账号窗口
			closeTeacherAccountShow:function(){
				this.teacherAccountShow = false;
			},
			//获取老师的账号信息
			getteacherAccount:function(){
				if(this.selections.length != 1){
					self.$Message.error({
								content: '请选择单条数据',
								duration: 10,
								closable: true
							});	
					return;
				}
           		var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/getTeacherAccountInfo';
            	this.$http.post(url,{"classesId":this.selections[0].classesId}).then(function(response) {
					if(response.data.success == true){
						
//						console.log(response.data.data)
						self.data2 = response.data.data
						self.teacherAccountShow = true;
		            }else if(response.data.success == false){
		            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
//		            		self.tableshow = false;
		            	}
					})
					.catch(function(error) {
						self.$Message.error({
							content: '系统发生错误：错误码00069',
							duration: 10,
							closable: true
						});
//						self.tableshow = false;
					});
			},
            exportexl:function(){
			
				var senddata = { 
           			"gradeId":this.gradeSelect,
					"classesId":this.classesSelect
				}
				var self = this;
            	let url = api.apidomain+'/tqes/web/tchTeacherEdition/exportFromClassesTeacherInfoExcel';
            	this.$http.post(url,senddata).then(function(response) {
					if(response.data.success == true){
//						////console.log(response.data.data)
						window.location.href = response.data.data;
						self.loading = false;
	            }else if(response.data.success == false){
	            		self.loading = false;
	            		self.$Message.error({
								content: response.data.msg,
								duration: 10,
								closable: true
							});	
	            	}
	            	
				})
				.catch(function(error) {
					self.loading = false;
					self.$Message.error({
							content: '系统发生错误：错误码00070',
							duration: 10,
							closable: true
						});
				});
				
			}  
			
		},
		watch:{
			settingSearchInfo:function(){
				this.settingSearchTeacher();
			}
		}
	}
</script>

<style>
	.active{
		background-color: #517edb;
		color: white;
	}
	.columnCellClass{
		height: 100px;
	}
</style>